/*
 * package com.fsxgt.datagrid.ds.handler;
 * 
 * import java.io.IOException; import java.net.UnknownHostException; import
 * java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays;
 * import java.util.Iterator; import java.util.List; import java.util.Map;
 * import java.util.concurrent.ExecutorService; import
 * java.util.concurrent.Executors; import java.util.function.Consumer;
 * 
 * import javax.sql.DataSource;
 * 
 * import org.apache.hadoop.conf.Configuration; import
 * org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import
 * org.apache.hadoop.hbase.HBaseConfiguration; import
 * org.apache.hadoop.hbase.HTableDescriptor; import
 * org.apache.hadoop.hbase.TableName; import
 * org.apache.hadoop.hbase.client.Admin; import
 * org.apache.hadoop.hbase.client.Connection; import
 * org.apache.hadoop.hbase.client.ConnectionFactory; import
 * org.apache.hadoop.hbase.client.Result; import
 * org.apache.hadoop.hbase.client.ResultScanner; import
 * org.apache.hadoop.hbase.client.Scan; import
 * org.apache.hadoop.hbase.client.Table;
 * 
 * import com.fsxgt.datagrid.ds.bo.ColumnInfo; import
 * com.fsxgt.datagrid.ds.bo.DatasourceJdbcBO; import
 * com.fsxgt.datagrid.ds.exception.DsException; import
 * com.mongodb.ServerAddress; import com.mongodb.client.MongoClient; import
 * com.mongodb.client.MongoIterable;
 * 
 * public class HbaseHandler implements DbHandler {
 * 
 * private MongoClient mongoClient;
 * 
 * public DatasourceJdbcBO config = null;
 * 
 * public String databaseName = null;
 * 
 * public static final String SPLIT_SCOLON=":";
 * 
 * private Admin admin; private Table table; private Configuration hbaseConf =
 * HBaseConfiguration.create(); private Connection connection = null; private
 * ExecutorService pool = Executors.newScheduledThreadPool(2);
 * 
 * private static List<ServerAddress> parseServerAddress(String rawAddress)
 * throws UnknownHostException { List<ServerAddress> addressList = new
 * ArrayList<>(); for (String address : Arrays.asList(rawAddress.split(","))) {
 * String[] tempAddress = address.split(":"); try { ServerAddress sa = new
 * ServerAddress(tempAddress[0], Integer.valueOf(tempAddress[1]));
 * addressList.add(sa); } catch (Exception e) { throw new
 * UnknownHostException(); } } return addressList; }
 * 
 * public HbaseHandler(DatasourceJdbcBO datasourceJdbcBO) throws DsException {
 * 
 * try { String[] zkAdress = datasourceJdbcBO.getZkAdress().split(SPLIT_SCOLON);
 * hbaseConf.set("hbase.zookeeper.quorum", zkAdress[0]);
 * hbaseConf.set("hbase.zookeeper.property.clientPort", zkAdress[1]); connection
 * = ConnectionFactory.createConnection(hbaseConf, pool); admin =
 * connection.getAdmin(); this.datasourceType =
 * datasourceJdbcBO.getDatasource(); this.config = datasourceJdbcBO;
 * }catch(IOException e) { throw new DsException(e); }
 * 
 * }
 * 
 * @Override public List<ColumnInfo> getColumnsByTableName(String schema, String
 * tableName) throws Exception { // TODO Auto-generated method stub
 * 
 * 
 * List<ColumnInfo> list = new ArrayList<>(); table =
 * connection.getTable(TableName.valueOf(tableName)); Scan scan = new Scan();
 * //Filter filter = new PageFilter(1); //scan.setFilter(filter);
 * scan.getStartRow(); ResultScanner scanner = table.getScanner(scan);
 * Iterator<Result> it = scanner.iterator(); if (it.hasNext()) { Result re =
 * it.next(); List<Cell> listCells = re.listCells(); for (Cell cell : listCells)
 * { ColumnInfo column=new ColumnInfo(); column.setName(new
 * String(CellUtil.cloneFamily(cell)) + ":" + new
 * String(CellUtil.cloneQualifier(cell))); list.add(column); } }
 * 
 * return list; }
 * 
 *//**
	 * @Title: getTableNames
	 * @Description: TODO(描述)
	 * @param schema
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getTableNames(java.lang.String)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public List<String> getTableNames(String schema) { // TODO
 * Auto-generated method stub
 * 
 * return null; }
 * 
 *//**
	 * @Title: getTableNames
	 * @Description: TODO(描述)
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getTableNames()
	 * @author liuyi
	 * @throws Exception
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public List<String> getTableNames() throws Exception { List<String>
 * list = new ArrayList<>(); Admin admin = connection.getAdmin(); TableName[]
 * names = admin.listTableNames(); for (int i = 0; i < names.length; i++) {
 * list.add(names[i].getNameAsString()); } return list; }
 * 
 *//**
	 * @Title: getColumnsBySql
	 * @Description: TODO(描述)
	 * @param querySql
	 * @return
	 * @throws SQLException
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getColumnsBySql(java.lang.String)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public List<ColumnInfo> getColumnsBySql(String querySql) throws
 * SQLException { // TODO Auto-generated method stub return null; }
 * 
 *//**
	 * @Title: getMaxIdVal
	 * @Description: TODO(描述)
	 * @param tableName
	 * @param key
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getMaxIdVal(java.lang.String,
	 *      java.lang.String)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public Object getMaxIdVal(String tableName, String key) { // TODO
 * Auto-generated method stub
 * 
 * 
 * return null; }
 * 
 *//**
	 * @Title: getSqlForMaxId
	 * @Description: TODO(描述)
	 * @param sql
	 * @param key
	 * @return
	 * @throws DsException
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getSqlForMaxId(java.lang.String,
	 *      java.lang.String)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public String getSqlForMaxId(String sql, String key) throws
 * DsException { // TODO Auto-generated method stub return null; }
 * 
 *//**
	 * @Title: getSqlForCount
	 * @Description: TODO(描述)
	 * @param sql
	 * @return
	 * @throws DsException
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getSqlForCount(java.lang.String)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public String getSqlForCount(String sql) throws DsException { //
 * TODO Auto-generated method stub return null; }
 * 
 *//**
	 * @Title: update
	 * @Description: TODO(描述)
	 * @param sql
	 * @param params
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#update(java.lang.String,
	 *      java.util.List)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public int update(String sql, List params) { // TODO Auto-generated
 * method stub return 0; }
 * 
 *//**
	 * @Title: queryForObject
	 * @Description: TODO(描述)
	 * @param sql
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#queryForObject(java.lang.String)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public Object queryForObject(String sql) { // TODO Auto-generated
 * method stub return null; }
 * 
 *//**
	 * @Title: queryForList
	 * @Description: TODO(描述)
	 * @param sql
	 * @param params
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#queryForList(java.lang.String,
	 *      java.util.List)
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public List<Map<String, Object>> queryForList(String sql, List
 * params) { // TODO Auto-generated method stub return null; }
 * 
 *//**
	 * @Title: getDatasourceType
	 * @Description: TODO(描述)
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getDatasourceType()
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public String getDatasourceType() { // TODO Auto-generated method
 * stub return datasourceType; }
 * 
 * private String datasourceType;
 * 
 *//**
	 * @Title: getDatasource
	 * @Description: TODO(描述)
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getDatasource()
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public DataSource getDatasource() { // TODO Auto-generated method
 * stub return null; }
 * 
 *//**
	 * @Title: getSchemas
	 * @Description: TODO(描述)
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getSchemas()
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public List<String> getSchemas() { // TODO Auto-generated method
 * stub
 * 
 * MongoIterable<String> dbs = mongoClient.listDatabaseNames(); List<String>
 * dbNames = new ArrayList<>(); dbs.forEach((Consumer<? super String>)
 * dbNames::add);
 * 
 * return dbNames;
 * 
 * }
 * 
 *//**
	 * @Title: getConfig
	 * @Description: TODO(描述)
	 * @return
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#getConfig()
	 * @author liuyi
	 * @date 2023-12-13 09:17:39
	 */
/*
 * @Override public DatasourceJdbcBO getConfig() { // TODO Auto-generated method
 * stub return this.config; }
 * 
 *//**
	 * @Title: runTest
	 * @Description: TODO(描述)
	 * @return
	 * @throws SQLException
	 * @see com.fsxgt.datagrid.ds.handler.DbHandler#runTest()
	 * @author liuyi
	 * @throws IOException
	 * @date 2023-12-13 09:17:39
	 *//*
		 * @Override public boolean runTest() throws IOException {
		 * 
		 * Admin admin = connection.getAdmin(); HTableDescriptor[] tableDescriptor =
		 * admin.listTables(); return tableDescriptor.length > 0;
		 * 
		 * 
		 * }
		 * 
		 * }
		 */